package com.bm;

import com.bm.util.JwtUtil;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jws;

import java.util.HashMap;
import java.util.Map;

import static com.bm.util.JwtUtil.parseToken;

public class Application {

    public static void main(String[] args) {

        // 创建令牌
        Map<String, Object> map = new HashMap<>();
        map.put("userName", "hangman");
        String token = JwtUtil.creatToken("hangman", map);
        System.out.println("Token: " + token);

        // 解析令牌
        Jws<Claims> claims = parseToken(token);
        System.out.println("Header Algorithm: " + claims.getHeader().getAlgorithm());
        System.out.println("Subject: " + claims.getBody().getSubject());
        System.out.println("Expiration: " + claims.getBody().getExpiration());
    }

}

